/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, {Component} from 'react';
import {Platform, StyleSheet, Text,Image, View,Dimensions} from 'react-native';
import RNThumbnail from 'react-native-thumbnail';
const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
  android:
    'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

type Props = {};
export default class App extends Component<Props> {
  render() {
    // RNThumbnail.get('https://e-power.oss-cn-shenzhen.aliyuncs.com/forum/201903/14/4330155256263426882.mp4')
    //     .then((result) => {
    //       console.log(result.path);
    //     });

    let imageSource = 'http://vimg.nosdn.127.net/enhanced/gNskp388C3wdPA.jpg';
    Image.prefetch(imageSource).then((result) => {
      //当预下载成功时，返回值result是true
      console.log(result);
    }).catch((error) => {
      //预下载图片失败
      console.log(error);
    });
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Welcome to React Native!</Text>
        <Text style={styles.instructions}>To get started, edit App.js</Text>
        <Text style={styles.instructions}>{instructions}</Text>
        <Image style={styles.posterImage} source={{uri: imageSource}} />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
  posterImage: {
    justifyContent:'center',
    height: Dimensions.get('window').width-220,
    width: Dimensions.get('window').width-100,
    marginTop: 10,
    borderRadius: 10,
    backgroundColor:'#56596a'
  },
});
